import random

# Rock-paper-scissors-lizard-Spock template


# The key idea of this program is to equate the strings
# "rock", "paper", "scissors", "lizard", "Spock" to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors

# helper functions

def name_to_number(name):
    # fill in your code below
    if name == 'rock':
        return 0
    elif name == 'Spock':
        return 1
    elif name == 'paper':
        return 2
    elif name == 'lizard':
        return 3
    elif name == 'scissors':
        return 4
    else:
        print 'INVALID NAME!'
        return None
    
    # convert number to a name using if/elif/else
    # don't forget to return the result!

    
def number_to_name(number):
    # fill in your code below
    if number == 0:
        return 'rock'
    elif number == 1:
        return 'Spock'
    elif number == 2:
        return 'paper'
    elif number == 3:
        return 'lizard'
    elif number == 4:
        return 'scissors'
    else:
        print 'INVALID NUMBER!'
        return None
    

    # convert name to number using if/elif/else
    # don't forget to return the result!


def rpsls(name): 
    
    # fill in your code below
    
    # convert name to player_number using name_to_number
    player_number = name_to_number(name)
    if player_number == None:
        print ''
        print 'Player choice is invalid!'
        return
    # compute random guess for comp_number using random.randrange()
    comp_number = random.randrange(0,5)
    # compute difference of player_number and comp_number modulo five
    difference_mod_5 = (player_number - comp_number) % 5    
    # use if/elif/else to determine winner
    # convert comp_number to name using number_to_name    
    # print results
    if difference_mod_5 == 1:
        player_wins = True
        computer_wins = False
    elif difference_mod_5 == 2:
        player_wins = True
        computer_wins = False
    elif difference_mod_5 == 3:
        player_wins = False
        computer_wins = True 
    elif difference_mod_5 == 4:
        player_wins = False
        computer_wins = True
    else:
        player_wins = 0
        computer_wins = 0
    
    
    if(player_wins==0 and computer_wins==0):
        print ''
        print 'Player chooses ' + name
        print 'Computer chooses ' + number_to_name(comp_number)
        print 'A Tie!'
    elif player_wins :
        print ''
        print 'Player chooses ' + name
        print 'Computer chooses ' + number_to_name(comp_number)
        print 'Player Wins!'
    else:
        print ''
        print 'Player chooses ' + name
        print 'Computer chooses ' + number_to_name(comp_number)
        print 'Computer Wins!'
     
    

    
# test your code
rpsls("rock")
rpsls("Spock")
rpsls("paper")
rpsls("lizard")
rpsls("scissors")

# always remember to check your completed program against the grading rubric


